package net.jumpengine.bean;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;

public class ImageButton extends ClickBase {
	private Image image;
	private boolean same;
	
	public ImageButton(int x, int y,Image image) {
		this(x, y, (int)image.getWidth(), (int)image.getHeight(),image);
	}

	public ImageButton(int x, int y, int width, int height,Image image) {
		this(x, y, width, height,0,image);
	}
	public ImageButton(int x, int y, int width, int height, int index,Image image) {
		super(x, y, width, height, index);
		this.image=image;
		same=width==image.getWidth() && height==image.getHeight();
	}

	@Override
	public void draw(GraphicsContext g) {
		if(!visible)return;
		if(same) {
			g.drawImage(image, x, y);	
		}else {
			g.drawImage(image, x, y, width, height);
		}
	}

}
